package com.addplus.townmall.server.scheduled.scheduletask;

import com.addplus.townmall.server.api.constant.StringConstant;
import com.addplus.townmall.server.api.mapper.demo.DemoUserMapper;
import com.addplus.townmall.server.api.mapper.town.ShopProductFightMapper;
import com.addplus.townmall.server.api.model.demo.DemoUser;
import com.addplus.townmall.server.api.model.town.ShopProductFight;
//import com.addplus.townmall.server.api.service.rest.demomodule.HelloService;
import com.addplus.townmall.server.api.utils.DataUtils;
import com.addplus.townmall.server.connector.redis.RedisSlaveTemplateManager;
import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.List;

//@Component
public class SchedulerTask {

    private int count = 0;

    @Reference
//    private HelloService helloService;

    @Autowired
    private DemoUserMapper demoUserMapper;

    @Autowired
    private RedisSlaveTemplateManager templateManager;

    private Logger logger = LoggerFactory.getLogger(SchedulerTask.class);

    @Scheduled(cron = "*/6 * * * * ?")
    private void process() throws Exception {
        DemoUser demoUser = demoUserMapper.getDemoUserWithDemoCar(1);
        logger.info(JSON.toJSONString(demoUser));
        String startupString = (String) templateManager.getSlaveTemlate().opsForValue().get(StringConstant.APP_STARTUP_GUIDE);
        logger.info(startupString);
        logger.info("this is scheduler task runing  " + (count++));
        //logger.info(JSON.toJSONString(helloService.getDenoManyProperty(1)));
    }

}
